package mqsmessage

import "encoding/json"

const OperationRecordCode = "00000001"      //操作日志记录
const TenantInitializationCode = "00000002" //租户初始化
const TenantSyncDictionary = "00000003"     //租户初同步字典
const TenantCopyTempCode = "TenantCopyTemp" //临时方法同步到 云系统总菜单控制
const TenantSyncMenuCode = "TenantSyncMenu" //全局菜单同步到租户

// Message 消息体
type Message struct {
	Code string //消息代码
	Data string //消息体
}
type TenantSyncMenuMessage struct {
	CategoryId int64
	MenusId    []int64
}

//OperationRecordMessage 操作日志

type OperationRecordMessage struct {
	Path          string //访问地址
	UserId        int64  //访问者
	IsAuth        bool   //是否有权限
	OperationTime string //操作时间
	RequestMethod string //请求方式
	UserAgent     string //客户端信息
	Params        string //请求参数
	Ip            string //请求IP
	TenantId      int32  //租户ID
}

// TenantInitialization 租户初始化
type TenantInitialization struct {
	TenantId int32
	Password string
	Phone    string
	Username string
}

// TenantDictionary 租户初同步字典
type TenantDictionary struct {
	TenantId int32
	Name     string
}

// MessageToText  文本化
func MessageToText(Code string, data any) (string, error) {
	MessageDataText, e := json.Marshal(data)
	if e != nil {
		return "", e
	}
	MessageData := Message{
		Code: Code,
		Data: string(MessageDataText),
	}
	MessageText, ee := json.Marshal(MessageData)
	if ee != nil {
		return "", ee
	}
	return string(MessageText), nil

}

// 临时的。
type TenantCopyTemp struct {
	TenantId int64
}
